The present invention relates to relational database management systems, and more particularly to typed view hierarchies for an object-relational database management system (ORDBMS).
More and more software applications are being written in object oriented languages such as C++ or Java. Over the past few years, object oriented database management systems (OODBMS) have been developed to serve this need. However, known object oriented database management systems do not provide the many features and the scalability of known is relational database management systems (RDBMS). In response to this need, vendors of relational database management systems have attempted to extend the functionality of their RDBMS products to capture the object oriented market. The result is an object-relational database management system (ORDBMS) which provides the application program with an object oriented view of its data while maintaining a relational treatment for queries and update operations.
The foundation of a relational database management system or RDBMS is a set of tables which hold the actual relational data. On top of the tables, the RDBMS provides a level of encapsulation known as xe2x80x9cviewsxe2x80x9d. The purpose of the views is to provide different xe2x80x9cviewsxe2x80x9d on the same set of data for different groups of clients. The different views protect both the data from being seen by unauthorized groups and the clients from being overwhelmed by information that is not useful. In addition, views provide pre-processing of the raw data.
It will be appreciated that for object-oriented applications a uniform table is too flat. In a RDBMS, all objects within a table are of the same form, i.e. the objects appear as homogeneous rows. As a result, an application that pushes various types of objects into the DBMS will need to add more semantics and thus the overhead for storing the object as a row is increased. When the object is queried these semantics need to be analyzed again by the application in order to deduce the type of the object. One approach to handling the additional semantics is to store each type of object in a separate table. Alternatively, the table can be enriched with additional typecode columns that need to be analyzed. Either way queries on these objects cannot be optimized by the DBMS since the DBMS is not aware of the added semantics and the mapping done by the application. Furthermore, the mapping imposes a higher load of coding on the application. The problem of mapping object oriented data into the relational model is often referred to as xe2x80x9cimpedance mismatchxe2x80x9d.
The SQL standard now provides a facility for creating typed table hierarchies within the DBMS. The DB2 product available from IBM has realized this feature of pushing the mapping of different objects into rows of a physical table into the DBMS through the use of a so-called hierarchy table for a physical representation and through the generation of so-called logical tables serving as query targets on the table hierarchy to project and filter the rows in the hierarchy table to match the requested type. The SQL standard also now provides for a facility to expand the concept of views over tables to typed view hierarchies over typed table hierarchies.
Existing prior systems typically result in large access graphs having very poor performance. Essentially every object in the hierarchy is mapped without exploiting the meta information of the requested classes and the one stored in the structure of the hierarchies.
Accordingly, there still remains a need for enriching tables and views in a relational database management system with the concept of hierarchies and typed rows comprising classes and objects.
The present invention provides a method for defining an efficient representation for the complete hierarchy that can be shared by multiple references from different classes.
The method according to the invention features a dense implementation which allows subsequent query rewrite to eliminate all unneeded access to physical tables. Advantageously, this reduces the access to nearly the one chosen when not using the view at all. Moreover, this is transparent and scaleable. As a cookie, the present invention overcomes cheaply the hurdles of insert and updating through the hierarchies, which for a straight forward solution would be expensive.
According to the invention, all views in the hierarchy are merged into a hierarchy view through the use of case expressions for mapping of view types and wrapping of overloaded column. Advantageously during this procedure the underlying logical tables are eliminated which results in a more straight forward query graph. Since the transformation is a non-loss transformation and condenses the type information within the case-expressions, then update, delete and insert operations can be resolved in the graph on a local level. Query rewrite can simplify these case-expressions with well known general rules and this minimizes the query to the nearly optimal case by eliminating the case-expressions and using the resulting predicates to drop non accessed table hierarchy from the graph.